package com.silverbox.shopper.mapper;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;

import com.silverbox.shopper.entity.HotGoodsWeek;

public interface HotGoodsWeekMapper {
    int deleteByPrimaryKey(Long id);

    int insert(HotGoodsWeek record);

    int insertSelective(HotGoodsWeek record);

    HotGoodsWeek selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(HotGoodsWeek record);

    int updateByPrimaryKey(HotGoodsWeek record);
    
    /*=================extend SQL==================*/
    /**
     * 按店铺查询某天在最火商品库里的数据
     * @param storeId 门店id
     * @return
     */
//    List<HotGoodsWeek> getHotGoodsWeekList(@Param(value = "storeId")Integer storeId, @Param(value = "startDate") String startDate, @Param(value = "endDate") String endDate);

	/**
	 * 更新本周最火
	 * @param storeId
	 * @param nowDate
	 * @param weekDate
	 */
	void updateHotByCallAble(@Param("storeId")Integer storeId, @Param("nowDate")String nowDate, @Param("weekDate")String weekDate);

	/**
	 * 获取本周最火商品
	 * @param storeId
	 * @param isHand
	 * @param maxNum
	 * @return
	 */
	List<HotGoodsWeek> getHotWeekGoods(@Param("storeId")Integer storeId, @Param("isHand")Integer isHand,@Param("maxNum")Integer maxNum);

	/**
	 * 获取原有的本周最火
	 * @param storeId
	 * @param todayStart
	 * @param todayEnd
	 * @return
	 */
	List<HotGoodsWeek> getOldHotGoodsWeek(@Param("storeId")Integer storeId, @Param("todayStart")String todayStart, @Param("todayEnd")String todayEnd);
	
	/**
	 * 删除系统统计出的本周最火
	 * @param storeId
	 * @param shopperPid
	 * @return
	 */
	int deleteHotGoodsSqlForSystemSet(@Param("storeId")Integer storeId, @Param("shopperPid")Integer shopperPid);
	
	/**
	 * 重新统计出本周最火商品及销量
	 * @return
	 */
	int insertHotGoodsSqlForSystemSet(@Param("createTime")Date createTime, @Param("hotGoodsList")List<HotGoodsWeek> hotGoodsList);
	/**
	 * 重新统计出本周最火商品及销量
	 * @param storeId
	 * @param shopperPid
	 * @return
	 */
	int updateHotGoodsSqlForCustomSet(@Param("totalVolume")Double totalVolume, @Param("storeId")Integer storeId, @Param("shopperPid")Integer shopperPid, @Param("goodsId")Integer goodsId, @Param("sizeId")Long sizeId);
	/**
	 * 重新统计出本周最火商品及销量
	 * @param storeId
	 * @param shopperPid
	 * @param nowDate
	 * @param weekDate
	 * @return
	 */
	List<HotGoodsWeek> selectHotGoodsSqlForSystemSet(@Param("storeId")Integer storeId, @Param("shopperPid")Integer shopperPid, @Param("nowDate")String nowDate, @Param("weekDate")String weekDate);
	/**
	 * 重新统计出自定义本周最火商品及销量
	 * @param storeId
	 * @param shopperPid
	 * @param nowDate
	 * @param weekDate
	 * @return
	 */
	List<HotGoodsWeek> selectHotGoodsSqlForCustomSet(@Param("storeId")Integer storeId, @Param("shopperPid")Integer shopperPid, @Param("nowDate")String nowDate, @Param("weekDate")String weekDate, @Param("goodsId")Integer goodsId, @Param("sizeId")Long sizeId);

	/**
	 * 根据店铺信息查询本周最火商品
	 * @param storeId
	 * @param shopperPid
	 * @return
	 */
	List<HotGoodsWeek> getCustomHotGoodsWeek(@Param("storeId")Integer storeId, @Param("shopperPid")Integer shopperPid);

    List<Map<String, Object>> selectIndexByStoreId(@Param("storeId") Integer storeId, @Param("orderType") int orderType);

    void updateIndexByStoreId(@Param("storeId") Integer storeId,@Param("orderType") int orderType);

    void updateHourByStoreId(@Param("storeId") Integer storeId,@Param("nowDate")String nowDate);
}